package com.longtop.perform.ar.web;

import java.util.HashMap;

import com.longtop.framework.base.BaseAction;
import com.longtop.intelliweb.action.IActionContext;
import com.longtop.intelliweb.action.IInitContext;
import com.longtop.intelliweb.view.Dataset;
import com.longtop.perform.ar.service.AssignService;

public class ArDgCustListAction extends BaseAction {

	protected final String DATASET_CUST = "Dataset_Cust";

	/**
	 * 系统共用：初始化调用
	 */
	public void init(IInitContext context) {
		super.init(context);
	}

	/**
	 * 本页jsp：初始化业务数据(覆写父类方法)
	 */
	public void thisPageInit(IInitContext context) {

	}

	public void getCusts(IActionContext context, boolean isFirst) {
		Dataset dataset_cust = context.getDataset(DATASET_CUST);
		HashMap map = new HashMap();
		AssignService assignService = this.getBean(AssignService.BEAN_ID);
		// 查询条件设置
		String custId = context.getElementValue("T_custId");
		String custName = context.getElementValue("T_custName");
		String cardType = context.getElementValue("T_certType");
		String cardNo = context.getElementValue("T_certNo");
		String orgId = context.getElementValue("orgId");
		String isAllocate = context.getElementValue("T_isAllocate");
		map.put("custId", custId);
		map.put("custName", custName);
		map.put("cardType", cardType);
		map.put("cardNo", cardNo);
		map.put("orgId", orgId);
		map.put("isAllocate", isAllocate);

		map.put("tablenames", "T_I1_INFO_DG_CUST");// 对公客户表名
		map.put("mastertablename", "T_AR_DG_CUST");

		// 当前第几页
		if (isFirst) {
			dataset_cust.setPageNo(1);
		}

		assignService.queryForPageByIbatis("arAssignSql.selectCustList", null, map, dataset_cust, false);
		// assignService.buildDatasetByAutoCount(context, "arAssignSql.selectCustList", map, dataset_cust, "cmd_load");
	}

	public void queryCusts(IActionContext context) {
		getCusts(context, true);
	}

	public void loadCusts(IActionContext context) {
		getCusts(context, false);
	}

}
